package com.prjsystem.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.prjsystem.common.constant.CMSConstant;
import com.prjsystem.entity.UserInfo;
import com.prjsystem.entity.WorkRequestDetail;
import com.prjsystem.entity.WorkRequestViewBean;
import com.prjsystem.service.WorkRequestService;

@SuppressWarnings("serial")
public class WorkRequestViewAction extends ActionSupport {
	private WorkRequestService workRequestService;	
	private WorkRequestViewBean workRequestViewBean=new WorkRequestViewBean();
	private WorkRequestDetail workRequestDetail=new WorkRequestDetail();

	public String init () {
		return SUCCESS;
	}
	//WR画面一览
	public String searchwrView() throws Exception {
		UserInfo userInfor = (UserInfo) ActionContext.getContext().getSession().get(CMSConstant.USERINFO);
		ActionContext ctx = ActionContext.getContext();
		ctx.getSession().put(CMSConstant.workRequestViewBean,null);
		ctx.getSession().put(CMSConstant.workRequestViewBean,workRequestViewBean);
		workRequestViewBean.setUserId(userInfor.getId());
		workRequestService.getWrView(workRequestViewBean);
		return SUCCESS;
	}
	//用wrId进行检索--seach
	public String searchBywrId() throws Exception {
		ActionContext ctx = ActionContext.getContext();
		ctx.getSession().put(CMSConstant.workRequestViewBean,null);
		ctx.getSession().put(CMSConstant.workRequestViewBean,workRequestViewBean);
		workRequestService.getWrView(workRequestViewBean);
		
		return SUCCESS;
    }
	public String wrBack() throws Exception {
		workRequestViewBean= (WorkRequestViewBean) ActionContext.getContext().getSession().get(CMSConstant.workRequestViewBean);
		workRequestService.getWrView(workRequestViewBean);
		
		return SUCCESS;
    }
	//根据wrId查询详细信息 --Look
	public String ListWrById() throws Exception {
    	workRequestService.getDetailWr(workRequestViewBean);
		return SUCCESS;
	}
    //进入添加画面的入口--add
    public String addDefault () {
    	workRequestService.addDetailWr(workRequestViewBean);
		return SUCCESS;
	}
    //编辑--edit
    public String editWr() throws Exception {
		workRequestService.getDetailWr(workRequestViewBean);
		return SUCCESS;
	}
    //利用wrId删除单条记录--delete
	public String deleteWr() throws Exception {
		workRequestService.deleteWr(workRequestViewBean);
		return SUCCESS;
	}
	
	public void setWorkRequestViewBean(WorkRequestViewBean workRequestViewBean) {
		this.workRequestViewBean = workRequestViewBean;
	}
	public WorkRequestViewBean getWorkRequestViewBean() {
		return workRequestViewBean;
	}
	public void setWorkRequestDetail(WorkRequestDetail workRequestDetail) {
		this.workRequestDetail = workRequestDetail;
	}
	public WorkRequestDetail getWorkRequestDetail() {
		return workRequestDetail;
	}
	public WorkRequestService getWorkRequestService() {
		return workRequestService;
	}
	public void setWorkRequestService(WorkRequestService workRequestService) {
		this.workRequestService = workRequestService;
	}	
}
